(function(){
    angular.module('app').controller("agbRoleCtrl",function($scope,proxy,$stateParams){
        $scope.permission = PERMISSION;
        $scope.filter = {
            roleType: $stateParams.type+"",
        }
        // 根据名字查询
        $scope.search = function (value) {
            $scope.filter.name = value;
            getList();
        }
        // 切换角色类型
        $scope.selectType = function(type) {
            $scope.filter.roleType = type+"";
            getList();
        }

        getList();

        function getList(current, pagesize) {
            var data = {
                'page': (current || 1)+"",
                'size': (pagesize || 20)+"",
                'filter': $scope.filter,
                "sort": ["cTime,1"],
                sTime : $scope.sTime,
                eTime : $scope.eTime
            };
            proxy.proxy({
                url: STATIC_URL.domian+'/dsp/pri/role/list',
                load: true,
                data: data,
                success: function(res){
                    // 获得列表
                    $scope.list = res.data.data;
                    $("#pageToolbar").html("");
                    $('#pageToolbar').Paging({
                        pagesize: pagesize || '20',
                        current: current || '1',
                        count:res.data.total,
                        toolbar:true,
                        'hash': false,
                        callback:getList
                    });
                }
            })
        }
    })
})();